home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_pyr_dirtmovercontrol.cog < prev    next >
Text File  |  1999-11-15  |  9KB  |  410 lines

  1. # Jones 3D Cog Script
  2. #
  3. # pyr_dirtmovercontrol.cog
  4. #    
  5. # Control all elements of the dirtmover precedent to its operation
  6. #
  7. # [RKD]
  8. #
  9. # (C) 1998 LucasArts Entertainment Company LLC. All Rights Reserved
  10. # ========================================================================================
  11. symbols
  12. message    startup
  13. message activated
  14.  
  15. # indyactors: 0 puts chain on, 1 pulls lever, 2 floats to talk about engine
  16. thing   indyactor0
  17. thing    indyactor1
  18. thing    indyactor2    
  19.  
  20. # world things
  21. thing   lever
  22. thing   chain
  23. thing    engine
  24. thing    engineshell        # invisible shell that provides the engine with collision
  25. thing   player        local
  26. thing    sparkghost
  27. thing    indywalk
  28.  
  29. # cameras and lookthings
  30. thing    chaincam        nolink
  31. thing    levercam        nolink
  32. thing    levercamlook    nolink
  33.  
  34. # related cogs
  35. cog        dirtmover
  36. cog        moveranim
  37. cog        pitfall
  38. cog        nolineup
  39.  
  40. # keyframes
  41. keyframe    indypull=in_pull_lever_down.key        local
  42. keyframe    leverpull=gen_lever.key                local
  43. keyframe    tohandsonhips=0in_stand1_bd_4.key     local
  44. keyframe    indythink=0in_thinking_4_4.key        local
  45.  
  46. # indy dialogue
  47. sound    hmmgenerator=pr09j01.wav    local
  48. sound    crankitup=pr09j02.wav        local
  49. sound    drivechain=pr09j03.wav        local
  50. sound    powertospare=pr09j04.wav    local
  51. sound    thatwontwork=inxj058.wav    local
  52. sound    notsure=inxj061.wav            local
  53.  
  54. # materials
  55. material    lamplight=lamp_hang_bot.mat                local
  56. material    sparkmat1=gen_a4sprite_rbblast.mat        local
  57. material    sparkmat2=gen_a4sprite_flash_purple.mat    local
  58.  
  59. # templates
  60. template    RedSparks=redsparks      local
  61. template    BlueSparks=bluesparks    local
  62.  
  63. # sound effects
  64. sound    chainsnd=pyr_chain_pickup.wav            local
  65. sound    leversnd=nub_lever_pull_c.wav            local
  66. sound    enginestart=pyr_gas_motor_start.wav        local
  67. sound    enginerun=pyr_gas_motor.wav                local
  68. sound    shock=sol_fuse_shock_c.wav                local
  69.  
  70. # music
  71. sound    patontheback=mus_gen_indycalm.wav    local
  72.  
  73. # variables
  74. int        actornum=0        local
  75. int        firsttime=1        local
  76. int        enginestatus=0    local
  77. int        curtrack=0        local
  78.  
  79. # subroutines
  80. flex    startscene=0.0        local
  81. flex    endscene=0.0        local
  82. flex    fixcams=0.0            local
  83. flex    nochainlines=0.0    local
  84. flex    startmover=0.0        local
  85. flex    stopmover=0.0        local
  86. end
  87.  
  88. code
  89. startup:
  90.     sleep(.01);
  91.     player = GetLocalPlayerThing();
  92.  
  93.     # turn lightposts off
  94.     SetMaterialCel(lamplight, 1);
  95.  
  96.     #make chain invisible
  97.     SetThingFlags(chain, 0x10);
  98.     
  99.     return;
  100.  
  101. # enginestatus values
  102. # 0 = nothing yet
  103. # 1 = chain applied
  104. # 2 = lever pulled
  105.  
  106. activated:
  107. # ---> Chain, Lever, Engine, EngineShell
  108.  
  109.     # if player uses chain on anything but invisichain, send lineup message
  110.     if ((GetSenderRef() != chain) && (GetCurItem(player) == 101))
  111.     {
  112.         # prepare player
  113.         if (MakeMeStop() == -1) return;
  114.         DeselectWeaponWait(player);
  115.     
  116.         # fix and swap player, move camera
  117.         StartCutscene(0);
  118.         SetActorFlags(player, 0x200000);
  119.         
  120.         # turn off engineshell to avoid camera screwup
  121.         SetThingFlags(engineshell, 0x80000);
  122.         
  123.         SetExtCamOffset('0.2 -0.15 0.1');
  124.         
  125.         sleep(.5);
  126.         
  127.         global15 = 1;
  128.         SendMessageEx(nolineup, user1, player, 0, 0, 0);
  129.                 
  130.         while (global15 == 0)
  131.         {
  132.             sleep(.2);
  133.         }
  134.  
  135.         sleep(.5);
  136.  
  137.         ClearActorFlags(player, 0x200000);
  138.         RestoreExtCam();
  139.         
  140.         # restore engineshell
  141.         ClearThingFlags(engineshell, 0x80000);
  142.         
  143.         EndCutscene();
  144.         return;
  145.     }
  146.  
  147.     # ===Chain, Lever, or Engine===
  148.     # if chain is invisible and player isn't holding it
  149.     if ((enginestatus == 0) && (GetCurItem(player) != 101))
  150.     {
  151.         # prepare player
  152.         if (MakeMeStop() == -1) return;
  153.         DeselectWeaponWait(player);
  154.     
  155.         call nochainlines;
  156.         return;
  157.     }
  158.     
  159.     # ===Chain===
  160.     # if chain is activated and it's invisible and player is holding the chain
  161.     if ((GetSenderRef() == chain) && (enginestatus == 0))
  162.     {
  163.         if (GetCurItem(player) != 101)
  164.         {
  165.             PlayVoice(player, thatwontwork, 1, 1);
  166.             return;
  167.         }
  168.         
  169.         # prepare player
  170.         if (MakeMeStop() == -1) return;
  171.         DeselectWeaponWait(player);
  172.         
  173.         actornum=0;
  174.         call startscene;
  175.             
  176.         # cut to chaincam
  177.         SetCameraFocus(2, chaincam);
  178.         SetCameraSecondaryFocus(2, chain);
  179.         SetCurrentCamera(2);
  180.         SetCameraFOV(100, 0, 0);
  181.  
  182.         # make chain visible
  183.         AISetLookThing(indyactor0, chain);
  184.         sleep(.5);
  185.         PlayMode(indyactor0, 60, 0);
  186.         sleep(.5);
  187.         PlaySoundThing(chainsnd, chain, 1, -1, -1, 0);
  188.         ClearThingFlags(chain, 0x10);
  189.  
  190.         # Indy: "Now I've got power to spare"
  191.         PlayVoice(indyactor0, powertospare, 1, 0);
  192.         sleep(1);
  193.         
  194.         # take chain out of inventory
  195.         ChangeInv(player, 101, -1);
  196.  
  197.         # update enginestatus
  198.         enginestatus = 1;
  199.  
  200.         call endscene;
  201.  
  202.         return;
  203.     }
  204.     
  205.     # ===Lever===
  206.     if (GetSenderRef() == lever)
  207.     {
  208.         if (enginestatus == 0) return;
  209.  
  210.         # if the machine is already started, refuse politely to turn it off
  211.         if (enginestatus == 2)
  212.         {
  213.             # prepare player
  214.             if (MakeMeStop() == -1) return;
  215.             DeselectWeaponWait(player);
  216.             
  217.             # fix and swap player, move camera
  218.             StartCutscene(0);
  219.             SetActorFlags(player, 0x200000);
  220.             
  221.             # turn off engineshell to avoid camera screwup
  222.             SetThingFlags(engineshell, 0x80000);
  223.             
  224.             SetExtCamOffset('0.2 -0.15 0.1');
  225.             
  226.             sleep(.5);
  227.         
  228.             PlayVoice(player, notsure, 1, 1);
  229.             
  230.             RestoreExtCam();
  231.             EndCutscene();
  232.             ClearActorFlags(player, 0x200000);
  233.             ClearThingFlags(engineshell, 0x80000);
  234.  
  235.             return;
  236.         }
  237.  
  238.         # prepare player
  239.         if (MakeMeStop() == -1) return;
  240.         DeselectWeaponWait(player);
  241.         
  242.         actornum = 1;
  243.         call startscene;
  244.  
  245.         # cut to levercam
  246.         SetCameraFocus(2, levercam);
  247.         SetCameraSecondaryFocus(2, levercamlook);
  248.         SetCurrentCamera(2);
  249.                 
  250.         #play anims
  251.         PlayKey(lever, leverpull, 4, 0x12, 0);
  252.         PlayKey(indyactor1, indypull, 4, 0x12, 0);
  253.         sleep(1.2);
  254.         PlaySoundThing(enginestart, engine, 1, -1, -1, 0);
  255.         PlaySoundThing(leversnd, lever, 1, -1, -1, 0);
  256.  
  257.         sleep(.5);
  258.         PlaySoundThing(enginerun, engine, 1, -1, 15, 1);
  259.  
  260.         #wait for a second while things start up
  261.         call startmover;
  262.  
  263.         # make transformer spark
  264.         PlaySoundThing(shock, sparkghost, 1, -1, -1, 0);
  265.         CreateThing(BlueSparks, sparkghost);
  266.         CreateThing(RedSparks, sparkghost);
  267.         MaterialAnim(sparkmat1, 10, 1);
  268.         MaterialAnim(sparkmat2, 10, 1);
  269.         sleep(1);
  270.                 
  271.         #move levercam towards conveyor
  272.         MoveToFrame(levercam, 1, 1);
  273.         MoveToFrame(levercamlook, 1, 1.25);
  274.         Sleep(1);
  275.         PlaySoundLocal(patontheback, 1, 0, 0, 0);
  276.  
  277.         # indy takes a walk
  278.         Sleep(1);
  279.         SetThingMaxRotVel(indyactor1, 250);
  280.         AISetLookThing(indyactor1, indywalk);
  281.         AISetMoveThing(indyactor1, indywalk, 1);
  282.         AISetLookPos(indyactor1, '0 -10 0');
  283.  
  284.         WaitForStop(levercam);
  285.         sleep(1);
  286.  
  287.            # turn lightposts on (while player isn't watching)
  288.         SetMaterialCel(lamplight, 0);
  289.  
  290.         # tell parts of the pit to be less deadly
  291.         SendMessage(pitfall, user1);
  292.  
  293.         # update enginestatus
  294.         enginestatus = 2;
  295.         
  296.         #endscene
  297.         call endscene;
  298.     
  299.         return;
  300.     }
  301.     return;
  302.  
  303. nochainlines:
  304.     
  305.     # fix and swap player, move camera
  306.     StartCutscene(1);
  307.     StopThing(player);
  308.     TeleportThing(indyactor2, player);
  309.     CopyPlayerHolsters(player, indyactor2);
  310.     ClearThingFlags(indyactor2, 0x80000);
  311.     SetActorFlags(player, 0x200000);
  312.     SetThingFlags(player, 0x80000);
  313.     
  314.     # turn off engineshell to avoid camera screwup
  315.     SetThingFlags(engineshell, 0x80000);
  316.     
  317.     SetExtCamOffset('0.2 -0.15 0.1');
  318.             
  319.     # if he hasn't commented on the chain yet, play deluxe dialogue
  320.     if (firsttime)
  321.     {
  322.         PlayVoice(indyactor2, hmmgenerator, 1, 0);
  323.         Sleep(3);
  324.         curtrack = PlayKey(indyactor2, tohandsonhips, 4, 0x12, 1);
  325.         PlayKey(indyactor2, indythink, 4, 0x14, 0);
  326.         Sleep(1);
  327.         PlayVoice(indyactor2, crankitup, 1, 1);
  328.         StopKey(indyactor2, curtrack, .5);
  329.         firsttime = 0;
  330.     }
  331.     else
  332.     {
  333.         PlayVoice(player, drivechain, 1, 1);
  334.     }
  335.  
  336.     sleep(1);
  337.  
  338.     SetThingFlags(indyactor2, 0x80000);
  339.     ClearThingFlags(player, 0x80000);
  340.     ClearActorFlags(player, 0x200000);
  341.  
  342.     RestoreExtCam();
  343.     
  344.     # restore engineshell
  345.     ClearThingFlags(engineshell, 0x80000);
  346.     
  347.     EndCutscene();
  348.     return;
  349.  
  350. startmover:
  351.     SendMessage(moveranim, user1);
  352.     SendMessage(dirtmover, user1);
  353.             
  354.     return;
  355.  
  356. stopmover:
  357.     SendMessage(moveranim, user2);
  358.     SendMessage(dirtmover, user2);
  359.     return;
  360.  
  361. startscene:
  362.     StartCutscene(1);
  363.     StopThing(player);
  364.     CopyOrientAndPos(indyactor0[actornum], player);
  365.     CopyPlayerHolsters(player, indyactor0[actornum]);
  366.     ClearThingFlags(indyactor0[actornum], 0x80000);
  367.     SetActorFlags(player, 0x200000);
  368.     SetThingFlags(player, 0x80000);
  369.     
  370.     return;
  371.         
  372. endscene:
  373.     call fixcams;
  374.     
  375.     CopyOrientAndPos(indyactor0[actornum], player);
  376.     SetThingFlags(indyactor0[actornum], 0x80000);
  377.     ClearThingFlags(player, 0x80000);
  378.     ClearActorFlags(player, 0x200000);
  379.  
  380.        # Establish a camera position near Indy and prep follow-cam...            
  381.     SetCameraPosition(1, VectorAdd(VectorTransformToOrient(player, '0.25 -0.1 0.0'), GetThingPos(player)));    
  382.  
  383.     SetCurrentCamera(1);
  384.     EndCutscene();
  385.  
  386.     # when all is done, clean up
  387.     if (enginestatus == 2)
  388.     {
  389.         DestroyThing(indyactor0);
  390.         DestroyThing(indyactor1);
  391.         DestroyThing(indyactor2);
  392.         DestroyThing(sparkghost);
  393.         DestroyThing(indywalk);
  394.         DestroyThing(chaincam);
  395.         DestroyThing(levercam);
  396.         DestroyThing(levercamlook);
  397.     }
  398.     return;
  399.  
  400. fixcams:
  401.     #reset camera settings
  402.     ResetCameraFOV(0, 0);
  403.     SetCameraPosInterp(2, 0);
  404.     SetCameraLookInterp(2, 0);
  405.     RestoreExtCam();
  406.     return;
  407.  
  408. end
  409.  
  410.